| Home | Code/Games | About me |
|---|
a python executable to play a number guessing game wich you can choose the difficulty of.
download
The code:
import random
from time import sleep
ng ="""
* * * * * *
* * * * *
* * * *
* * * * * * *** * *
* * * * * * * * * * *
---------------------------------------
"""
print(ng)
tries = 0
def check_answer(dfclty, nswr):
global tries
if tries == 0:
input_answer = input("Guess my number (1-{}): ".format(dfclty))
else:
input_answer = input("Wrong try again: ")
if str(nswr) == str(input_answer):
tries += 1
print("\nThat is correct")
print(f"attempt count {tries}")
tries = 0
else:
tries += 1
check_answer(difficulty, answer)
running = True
while running:
difficulty = input("\nhighest number in the range: ")
answer = random.randint(1, int(difficulty))
check_answer(difficulty, answer)
again = input("\nplay again? (y/n) ")
if str(again).lower() == "y":
pass
elif str(again).lower() == "n":
running = False
else:
print('\nerror')
break
goodbye ="""
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░░░▄▄▀▀▀▀▀▄░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░░▄▀░░░░░░░▀▄░░░░░░░░░░░░░░░░░░░░░░░░░░
░▄▀░░░▄▄░░░░▀▀▀▀▀▀▀▄▄▀▀▀▀▀▀▀▀▀▀▀▀▄▄░░░░
░█░░░░██░░░░░░░░░░░░░░░░░░░░░░░░░░░▀▄░░
░█░░░░██▄████▄░██▄░░░░▄██░▄████▄░░░░▀▄░
░█░░░░██▀░░▀██▄░██▄░░██▀░██▀░▄██░░░░░█░
░█░░░░██░░░░███░░█████▀░░██▄█▀▀░░░░░░█░
░█░░░░███▄▄███▀░░░▀██▀░░░▀██▄▄▄██░░░░█░
░▀▄░░░░▀▀▀▀▀▀░░░░░██▀░░░░░░▀▀▀▀▀░░░░░█░
░░▀▄░░░░░░░░░░░░░██▀░░░▄▄░░░░░░░░░▄▄▀░░
░░░░▀▀▀▀▀▀▀▀▀▄░░░▀▀░░░▄▀░▀▀▀▀▀▀▀▀▀░░░░░
░░░░░░░░░░░░░▀▄░░░░░░▄▀░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░▀▀▀▀▀▀░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
"""
print(goodbye)
sleep(1)